//#preprocess
package com.oc.claimobs.bb.ui;

import net.rim.device.api.ui.Field;
import net.rim.device.api.ui.FocusChangeListener;
import net.rim.device.api.ui.Screen;
//#ifndef HAS_KEYBOARD
/*
//#endif
import net.rim.device.api.ui.VirtualKeyboard;
//#ifndef HAS_KEYBOARD
 */
//#endif

public class TouchScreenFieldFocusChangeListener implements FocusChangeListener {

	private Screen screen = null;

	public TouchScreenFieldFocusChangeListener(Screen screen) {
		this.screen = screen;
	}

	public void focusChanged(Field field, int eventType) {
		if (screen != null) {
			if (eventType == FocusChangeListener.FOCUS_LOST) {
				//#ifndef HAS_KEYBOARD
				/*
				//#endif
				if (VirtualKeyboard.isSupported()
						&& screen.getVirtualKeyboard() != null) {
					screen.getVirtualKeyboard().setVisibility(VirtualKeyboard.HIDE);
				}
				//#ifndef HAS_KEYBOARD
				 */
				//#endif

				
			}
			if (eventType == FocusChangeListener.FOCUS_GAINED) {
				//#ifndef HAS_KEYBOARD
				/*
				//#endif
				if (VirtualKeyboard.isSupported()
						&& screen.getVirtualKeyboard() != null) {
					screen.getVirtualKeyboard().setVisibility(VirtualKeyboard.SHOW);
				}
				//#ifndef HAS_KEYBOARD
				 */
				//#endif

			}
		}
	}

}
